package tag.doABC2
{
	import flash.utils.ByteArray;
	
	import tag.Tag;
	
	import util.UTF8;

	public class DoABC2 extends Tag
	{
		public var flags:uint = 0;
		
		public var name:String = "";
		
		public var abcFile:ABCFile = null;
		
		public function DoABC2()
		{
			_id = 82;
		}
		
		public function handler(bytes:ByteArray):void
		{
			this.flags = bytes.readByte();
			bytes.readByte();
			bytes.readByte();
			bytes.readByte();
			this.name = this.readName(bytes);
			if(abcFile == null){
				abcFile = new ABCFile();
			}
			abcFile.handler(bytes);
		}
		
		public function readName(bytes:ByteArray):String
		{
			var arr:Array = [];
			var byte:int = 0;
			while(true){
				byte = bytes.readByte();
				if(byte == 0){
					break;
				}
				arr.push(byte);
			}
			return UTF8.decode(arr);
		}
	}
}